﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace NSsh.Common.Utility
{
    public class Log4netListener : TraceListener
    {
        public override bool IsThreadSafe
        {
            get { return true; }
        }

        public override void Write(string message)
        {
            Write((object)message, null);
        }

        public override void Write(object o)
        {
            Write(o, null);
        }

        public override void Write(object o, string category)
        {
            // Come up with a useful default logger name
            if (category == null || category.Length == 0)
            {
                category = "Log4NetListener";
            }
            log4net.LogManager.GetLogger(category).Info(o);
        }

        public override void Write(string message, string category)
        {
            Write((object)message, category);
        }

        public override void WriteLine(string message)
        {
            Write(message);
        }

        public override void WriteLine(object o)
        {
            Write(o);
        }

        public override void WriteLine(object o, string category)
        {
            Write(o, category);
        }

        public override void WriteLine(string message, string category)
        {
            Write(message, category);
        }
    }
}
